﻿using System;

namespace LuceneSearcher
{
    public class SearchResult : IEquatable<SearchResult>
    {
        public int NewsId { get; set; }

        public int BestMatchNewsId { get; set; }

        public double BestMatchScore { get; set; }

        #region Implementation of IEquatable<SearchResult>

        public bool Equals(SearchResult other)
        {
            // Check whether the compared object is null.
            if (ReferenceEquals( other, null )) return false;

            // Check whether the compared object references the same data.
            if (ReferenceEquals( this, other )) return true;

            // Check whether the SearchResult's properties are equal.
            return NewsId.Equals( other.NewsId ) && BestMatchNewsId.Equals( other.BestMatchNewsId );
        }

        #endregion

        public override int GetHashCode()
        {
            int hashNewsId = NewsId.GetHashCode();
            int hashBestMatchNewsId = BestMatchNewsId.GetHashCode();

            return hashNewsId ^ hashBestMatchNewsId;
        }
    }
}
